package com.kexio.core.data;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;

import com.kexio.core.data.config.CacheConfig;
import com.kexio.core.data.config.MyBatisConfig;
import com.kexio.core.properties.CoreProperties;

import jakarta.annotation.PostConstruct;

/**
 * Kexio数据访问层自动配置
 * 
 * 功能说明：
 * - 自动配置MyBatis-Plus
 * - 自动配置Redis和本地缓存
 * - 提供基础实体类和数据访问组件
 * 
 * @author Kexio
 * @since 1.0.0
 */
@AutoConfiguration
@EnableConfigurationProperties(CoreProperties.class)
@ConditionalOnProperty(name = "kexio.core.data.enabled", havingValue = "true", matchIfMissing = true)
@Import({
    MyBatisConfig.class,
    CacheConfig.class
})
public class DataAutoConfiguration {

    private static final Logger log = LoggerFactory.getLogger(DataAutoConfiguration.class);

    @PostConstruct
    public void init() {
        log.info("==> Kexio Core Data模块已启用");
        log.debug("Data模块包含: MyBatis-Plus配置、缓存配置、基础实体类");
    }
}
